package org.grow.erp.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.base.MoreObjects;
import lombok.Data;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * @Author: xwg
 * @CreateDate: 2022/1/19
 */

@Data
@Entity
public class OutStockMaterialDetail {

    @EmbeddedId
    private OutStockMaterialDetailId OutStockMaterialDetailId;

    //    材料编码	存货名称		单位	数量	单价	金额
    private String materialCode;
    /*两个冗余字段*/
    private String materialName;
    private String unit;


    private Integer quantity;
    private BigDecimal unitPrice;
    /*冗余计算属性*/
    private BigDecimal amount;

    @ManyToOne()
    @JoinColumn(name = "outStockFk")
    // 让当前声明的java/id="/someBillFk"取值 为当前列JoinColumn(name = "someBillFk")
    @MapsId("outStockFk")
    @JsonIgnore
    private OutStockBill outStockBill;

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("OutStockMaterialDetailId", OutStockMaterialDetailId)
                .add("materialCode", materialCode)
                .add("materialName", materialName)
                .add("unit", unit)
                .add("quantity", quantity)
                .add("unitPrice", unitPrice)
                .add("amount", amount)
                .toString();
    }
}
